package init

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto/rpc"
	"api-gateway/pkg"
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
)

func InitVideoRpc() {
	serviceConfig := pkg.ServiceConfig{
		Name:    "video_service",
		Tags:    []string{"videoApi"},
		Port:    50051,
		Address: "127.0.0.1",
	}
	consul := pkg.NewConsul("14.103.175.69:8500")
	err := consul.Register(serviceConfig)
	if err != nil {
		return
	}
	flag.Parse()
	conn, err := grpc.NewClient("127.0.0.1:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	config.VideoRpcClient = __.NewVideoClient(conn)
}
